<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "write_person".
 *
 * @property integer $id
 * @property integer $uid
 * @property integer $write_question_id
 * @property string $readtheme
 * @property string $listentheme
 * @property string $readhand1
 * @property string $readhand2
 * @property string $readhand3
 * @property string $listenhand1
 * @property string $listenhand2
 * @property string $listenhand3
 * @property string $content
 * @property integer $type
 * @property integer $time
 *
 * @property WriteQuestion $writeQuestion
 */
class WritePerson extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'write_person';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uid', 'write_question_id', 'content', 'type'], 'required'],
            [['uid', 'write_question_id', 'type', 'time'], 'integer'],
            [['readtheme', 'listentheme', 'readhand1', 'readhand2', 'readhand3', 'listenhand1', 'listenhand2', 'listenhand3', 'content'], 'string'],
            [['write_question_id'], 'exist', 'skipOnError' => true, 'targetClass' => WriteQuestion::className(), 'targetAttribute' => ['write_question_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'uid' => 'Uid',
            'write_question_id' => 'Write Question ID',
            'readtheme' => 'Readtheme',
            'listentheme' => 'Listentheme',
            'readhand1' => 'Readhand1',
            'readhand2' => 'Readhand2',
            'readhand3' => 'Readhand3',
            'listenhand1' => 'Listenhand1',
            'listenhand2' => 'Listenhand2',
            'listenhand3' => 'Listenhand3',
            'content' => 'Content',
            'type' => 'Type',
            'time' => 'Time',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getWriteQuestion()
    {
        return $this->hasOne(WriteQuestion::className(), ['id' => 'write_question_id']);
    }
}
